﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Mixr
{
    public partial class ChooseMedia : Form
    {
        List<Movie> choices = new List<Movie>();
        Movie final = new Movie();
        public ChooseMedia()
        {
            InitializeComponent();
        }


        AddLocalMedia mainForm;

        public Movie getMovie()
        {
            return final;
        }

        public ChooseMedia(AddLocalMedia mainForm, List<Movie> uchoices)
        {
            this.mainForm = mainForm;
            choices = uchoices;
            InitializeComponent();

            foreach(Movie choice in choices)
            {
                MediaList.Items.Add(choice.output());
            }
        }

        private void ChooseMedia_Load(object sender, EventArgs e)
        {

        }

        private void Select_Click(object sender, EventArgs e)
        {
            for (int x = 0; x < MediaList.Items.Count; x++)
            {
                if (MediaList.Items[x].Selected)
                {
                    final = choices[x];
                }
            }
            DialogResult = DialogResult.OK;
            this.Close();
            
        }

        private void MediaList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (MediaList.SelectedItems.Count > 0)
            {

                for (int x = 0; x < MediaList.Items.Count; x++)
                {
                    if (MediaList.Items[x].Selected)
                    {
                        coverImage.Image = choices[x].getImage();
                    }
                }
            }
        }

        private void CancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
